package com.adapterpattern;

import com.adapterpattern.adapter.Phone;
import com.adapterpattern.adapter.impl.PhoneAdapter;
import com.adapterpattern.iface.Charger;
import com.adapterpattern.iface.impl.TypeBCharger;
import com.adapterpattern.iface.impl.TypeCCharger;

public class Test {
    public static void main(String[] args) {
        // 适配器显式调用接口TypeBCharger
        Phone oppo = new PhoneAdapter();
        Charger oppo_charger = new TypeBCharger();
        oppo.charge(oppo_charger);

        // 适配器显式调用接口TypeCCharger
        Phone huawei = new PhoneAdapter();
        Charger huawei_charger = new TypeCCharger();
        huawei.charge(huawei_charger);
        /*
            通过PhoneAdapter可以使用同一个PhoneAdapter().charge()将多个无关联的类关联在一起，提高类的复用性
         */
    }
}
